package com.BraveY.Demo10;

public class StudentTest implements Comparable<StudentTest> {
    private String name;
    private int yu;
    private int shu;
    private int ying;

    public StudentTest() {
    }

    public StudentTest(String name, int yu, int shu, int ying) {
        this.name = name;
        this.yu = yu;
        this.shu = shu;
        this.ying = ying;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getYu() {
        return yu;
    }

    public void setYu(int yu) {
        this.yu = yu;
    }

    public int getShu() {
        return shu;
    }

    public void setShu(int shu) {
        this.shu = shu;
    }

    public int getYing() {
        return ying;
    }

    public void setYing(int ying) {
        this.ying = ying;
    }

    @Override
    public String toString() {
        return "StudentTest{" +
                "name='" + name + '\'' +
                ", yu=" + yu +
                ", shu=" + shu +
                ", ying=" + ying +
                '}';
    }

    @Override
    public int compareTo(StudentTest o) {
        int result = this.yu - o.yu;
        result = result == 0 ? this.shu - o.shu : result;
        result = result == 0 ? this.ying - o.ying : result;
        result = result == 0 ? this.name.compareTo(o.name) : result;
        return result;
    }
}
